<template>
  <div>
    <!--基本信息  -->
    <FormPanel ref="FormPanel" :list="initForm" :cols="3" :formType="formType" :labelWidth="160" :isSubmitBtn="false" @formChange="formChangeHandle" class="mtop" />
    <BaseDialog :visible.sync="isSearch" :title="'经销商查询'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <DealerSearcher :rowData="upperData" @close="upperClose" />
    </BaseDialog>
    <BaseDialog :visible.sync="companySearch" :title="'公司查询'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <CompanySearcher :rowData="companyData" @close="companyClose" />
    </BaseDialog>
  </div>
</template>

<script>
import { getAppId } from '@/assets/js/auth'; //获取登录用户

import { region } from '@/api/cms-common/region'; //行政区域
import { getRegion, getCommunity } from '@/api/cms-common/dealerdata/index'; //事业部，办事处

import { dictionary } from '@/utils/dictMixin';
import * as types from '@/api/cms-api/origin/originInfo/types';
import * as constructTypes from '@/api/cms-api/origin/construct/dealer/types';

import { dealerCommon, isArcfox } from '@/api/cms-api/origin/commonDealerType'; //经销商类型工具类
import {phoneAndSolidify,email, numberCheck, salesCode8, timeHourAndMin,phoneAndSolidifyNew} from '@/utils/validate.js';
import DealerSearcher from '@/pages/cms-pages/origin/originInfo/serviceDealerForm/DealerSearcher.vue';
import CompanySearcher from '@/pages/cms-pages/origin/originInfo/serviceDealerForm/CompnaySearcher.vue';

import vm from './bridge';
import moment from "moment";

export default {
  mixins: [dictionary, region, dealerCommon],
  components: {DealerSearcher,CompanySearcher},
  model: {
    prop: 'pdata',
    event: 'click'
  },
  props: {
    pdata: {
      type: Object,
      default: () => ({ auditStatus: -1 })
    },
    formType: {
      type: String,
      required: true
    },
    formOptions: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      opneKey: 1,
      upperData: {},
      isSearch: false,
      companyData: {},
      companySearch: false,
      hiddenFormData: {
      },
    };
  },
  mounted() {
    //初始化省份
    this.initProvince();

  },
  methods: {
    //初始化数据
    init() {
      // //经销商类型
      // if (this.formType != 'show') {
      //   if (this.formType == 'edit') {
      //     //如果是edit并且是空数据，则恢复填写状态
      //     if (!this.pdata.dealerType) {
      //       this.initForm.find(x => x.fieldName === 'dealerType').disabled = false;
      //     }
      //   } else if (this.formType == 'add') {
      //     //触发事件
      //     vm.$emit('changeDealerType', types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER);
      //     this.changeDealerTypeToDep(types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER);
      //   }
      //   if (this.pdata.dealerType) {
      //     //触发事件
      //     vm.$emit('changeDealerType', this.pdata.dealerType);
      //     this.changeDealerTypeToDep(this.pdata.dealerType, false);
      //   }
      // }
      this.initForm.forEach(x => {
        //回显下拉选需要的ID
        if (x.fieldName === 'dealerType') {
        } else if (x.fieldName === 'ownBrand') {
          //体系内品牌（后台存的是字符串，用‘,’拼接的，回显得转成数字的数组）
          if (this.pdata[x.fieldName]) {
            let list = this.pdata[x.fieldName].split(',');
            this.pdata[x.fieldName] = list.map(x => parseInt(x));
          } else {
            //默认值
            this.pdata[x.fieldName] = [];
          }
        }
        //回显数据
        if (this.pdata[x.fieldName]) {
          x.initialValue = this.pdata[x.fieldName];
        }
      });
      //添加级联下拉选（初始化市，区）
      this.initRegion(this.pdata.provinceId, this.pdata.cityId);
    },

    //获取事业部下拉列表数据
    async getDeptData() {
      const res = await getRegion();
      if (res.resultCode === 200) {
        this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      }
    },
    //表单验证通过后
    formChangeHandle(val) {
      this.pdata = Object.assign(this.pdata, val);
      //传递数据到父组件里
      this.$emit('click', this.pdata);
      //触发外部的事件，以标志着本表单已经准备完毕
      // this.$emit('formchange', this.pdata);
    },
    //开放的提交方法
    async saveDialog() {
      let flag = true;
      let err = this.$refs.FormPanel.SUBMIT_FORM();
      await this.$refs.FormPanel.$refs.form.validate().then(res => {
        console.log("res1:", res);
      }).catch(err => {
        console.log("err1:", err);
        flag = false;
      });
      console.log("flag:", flag);
      return flag;
      // this.$notify.warning({title: '提示信息',message:'只能选择一条记录'});
    },
    //经销商类型变更时
    changeDealerType(value) {
      //根据类型处理验证
      if (types.DEALER_INFO_DEALER_TYPE_4S === value) {
        //4S
        vm.changeForm(this.initForm, '4S', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_SINGLE_AFTER_SALE === value) {
        //单一售后
        vm.changeForm(this.initForm, 'SH', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_SINGLE_SALE === value) {
        //单一销售
        vm.changeForm(this.initForm, 'XS', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_DIRECT_SHOP === value) {
        //SPACE
        vm.changeForm(this.initForm, 'SPACE', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_NO_DIRECT_SHOP === value) {
        //RACE
        vm.changeForm(this.initForm, 'RACE', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER === value) {
        //大客户
        vm.changeForm(this.initForm, 'DKH', false);
        vm.clearValidate(this.$refs.FormPanel);
      }
      //另做处理，不是简单的起用禁用(显示，不显示)
      //维修资质： 4S和单一售后必填，单一销售和SPACE RACE时灰色不填
      //SPACE和RACE的经销商级别、展厅级别、售后级别及其他售后专用字段不显示
      //SPACE，RACE
      // if(types.DEALER_INFO_DEALER_TYPE_DIRECT_SHOP === value || types.DEALER_INFO_DEALER_TYPE_NO_DIRECT_SHOP === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = true;
      // //4S店
      // }else if(types.DEALER_INFO_DEALER_TYPE_4S === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // //单一销售
      // }else if(types.DEALER_INFO_DEALER_TYPE_SINGLE_SALE === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // //单一售后
      // }else if(types.DEALER_INFO_DEALER_TYPE_SINGLE_AFTER_SALE === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // }else{
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // }
    },
    //根据大客户类型变更事业部
    changeDealerTypeToDep(value, isChear = true) {
      //变更其事业部(包不好含大客户专属的机构)
      if (isChear) {
        this.initForm.find(item => item.fieldName === 'deptId').initialValue = '';
      }
      if (types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER === value) {
        this.getBigcustomerData();
      } else {
        this.getNotBigcustomerData();
      }
    },
    //根据不同的状态展现不同的选项（如果直接在经销商信息维护里添加只能选择大客户）
    createDealerTypeByType() {
      if (this.formOptions.formType === types.DEALER_INFO_FORM_STATUS_MAINTAIN_OEM) {
        //只能选择大客户
        return this.getOriginInfoDealerTypeToNotDisabled();
        //return this.createDictList(2538)
      } else {
        return this.getOriginInfoDealerType();
      }
    },
    //初始化市，区
    initRegion(provinceId, cityId) {
      this.initCity(provinceId, false);
      this.initTown(cityId, false);
    },
    //初始化所在省份
    async initProvince() {
      let pl = await this.createRegionList();
      this.initForm.find(item => item.fieldName === 'provinceId').itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId, flag = true) {
      if (!provinceId || provinceId == null || typeof provinceId == 'undefined') {
        return;
      }
      let city = this.initForm.find(item => item.fieldName === 'cityId');
      //清空下级数据
      if (flag) {
        city.initialValue = '';
        let district = this.initForm.find(item => item.fieldName === 'districtId');
        district.initialValue = '';
        district.itemList = [];
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      city.itemList = cl;
    },
    //初始化所在县市数据
    async initTown(cityId, flag = true) {
      if (!cityId || cityId == null || typeof cityId == 'undefined') {
        return;
      }
      let district = this.initForm.find(item => item.fieldName === 'districtId');
      //清空下级数据
      if (flag) {
        district.initialValue = '';
      }
      let td = this.cityData[cityId].children;
      let tl = this.createSubRegionList(td);
      //部分城市为县级市，没有县区的下级数据
      if (tl.length == 0) {
        district.rules.required = false;
        district.itemList = [];
        this.$refs.FormPanel.$refs.form.clearValidate();
      } else {
        district.rules.required = false;
        district.itemList = tl;
      }
    },
    //获取事业部下拉列表数据(只有‘大客户事业部’)
    async getBigcustomerData() {
      const dictList = await this._$getBigcustomerData();
      //if (res.resultCode === 200) {
      //this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      //}
      this.initForm.find(item => item.fieldName === 'deptId').itemList = dictList;
    },
    //获取事业部下拉列表数据(不包含‘大客户事业部’)
    async getNotBigcustomerData() {
      const dictList = await this._$getNotBigcustomerData();
      //if (res.resultCode === 200) {
      //this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      //}
      this.initForm.find(item => item.fieldName === 'deptId').itemList = dictList;
    },
    //事业部下拉改变执行方法，级联查询该事业部下的办事处
    async changeDeptSelect(deptId, flag = true) {
      let initForm$officeId = this.initForm.find(item => item.fieldName === 'officeId');
      if (!deptId) {
        initForm$officeId.initialValue = '';
        initForm$officeId.itemList = [];
      } else {
        if (flag) {
          //正常的级联，清空原来选择的数据
          initForm$officeId.initialValue = '';
        }
        const res = await getCommunity(deptId);
        if (res.resultCode === 200) {
          initForm$officeId.itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
        }
      }
    },
    //表单数据
    initFormFun() {
      let isNotAdd = this.formType != 'add';
      let isCompanyDisabled = this.formOptions.lastTimeSendToDms != null;
      let bt = { required: true, message: '必填', trigger: ['change', 'blur'] };
      let districtChangeBt = { required: false, message: '必填', trigger: ['change', 'blur'] };
      let btl = [bt,];
      let sj = { pattern: /^1[2-9]\d{9}$/, message: '请填写正确的手机号', trigger: ['change', 'blur'] };
      let yc = { hidden: true };
      return [
        {
          type: 'INPUT',
          label: '所属公司id',
          fieldName: 'dealerCompanyId',
          placeholder: '请选择',
          initialValue: '',
          hidden: true,
        },
        {
          type: 'INPUT',
          label: '所属公司代码',
          fieldName: 'dealerCompanyCode',
          placeholder: '请选择',
          initialValue: '',
          hidden: true,
        },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'dealerCode',
          placeholder: '请输入',
          initialValue: '',
          disabled: true,
          maxlength: 30,
          rules: [
            bt
            // { validator: salesCode8, trigger: 'blur'}
          ],
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          rows: 1,
          initialValue: '',
          placeholder: '请输入',
          maxlength: 30,
          rules: btl,
        },
        {
          type: 'INPUT',
          label: '经销商简称',
          fieldName: 'dealerShortname',
          placeholder: '请输入',
          initialValue: '',
          maxlength: 30,
          rules: btl,
        },
        {
          type: 'INPUT',
          label: '所属公司',
          fieldName: 'dealerCompanyName',
          placeholder: '请选择',
          initialValue: '',
          disabled: isCompanyDisabled,
          rules: btl,
          unitRender: () => {
            return (
              <div>
              <el-button icon="el-icon-search" onClick={() => this.companyOpen()}></el-button>
            </div>
          );
          }
        },
        {
          type: 'INPUT',
          label: '经销商名称（英文）',
          fieldName: 'dealerNameEn',
          rows: 1,
          initialValue: '',
          placeholder: '请输入',
          maxlength: 30,
        },
        {
          type: 'SELECT',
          label: '建店类型',
          fieldName: 'constructType',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1727'),
          rules: btl,
        },
        {
          type: 'SELECT',
          label: '建店级别',
          fieldName: 'constructLevel',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1720'),
          rules: btl,
        },
        {
          type: 'SELECT',
          label: '经销商星级',
          fieldName: 'shopLevel',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1723'),
        },
        {
          type: 'SELECT',
          label: '经营状态',
          fieldName: 'dealerStatus',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1724'),
          rules: btl,
          change: val => {
            this.changDealerStatus(val);
          },
        },
        {
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '请选择',
          initialValue: '',
          itemList: [],
          rules: btl,
          change: props => {
            this.initCity(props);
          }
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '请选择',
          initialValue: '',
          itemList: [],
          change: props => this.initTown(props),
          rules: btl,
        },
        {
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '请选择',
          initialValue: '',
          itemList: [],
          rules: districtChangeBt,
        },
        {
          type: 'INPUT',
          label: '展厅地址',
          fieldName: 'showroomAddress',
          selfCols: 2,
          rows: 1,
          initialValue: '',
          placeholder: '请输入',
          maxlength: 70,
          // rules: btl,
        },
        {
          type: 'SELECT',
          label: '经销商性质',
          fieldName: 'shopProperty',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1622'),
        },
        {
          type: 'INPUT',
          label: '热线电话',
          fieldName: 'salesLine',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 16,
          rules: [
            bt,,
            { validator: phoneAndSolidifyNew, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: '业务联系人',
          fieldName: 'salesLinkMan',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 15,
          rules: btl,
        },
        {
          type: 'INPUT',
          label: '联系方式',
          fieldName: 'salesLinkManTel',
          rows: 1,
          initialValue: '',
          placeholder: '请输入',
          maxlength: 16,
          rules: [
            bt,,
            { validator: phoneAndSolidifyNew, trigger: 'blur'}
          ]
        },
        {
          type: 'DATE',
          format: 'yyyy-MM-dd',
          dateType: 'exactdate',
          label: '入网时间',
          fieldName: 'joinTime',
          initialValue: '',
          placeholder: '请输入',
          rules: btl,
        },
        {
          type: 'DATE',
          format: 'yyyy-MM-dd',
          dateType: 'exactdate',
          label: '注销时间',
          fieldName: 'offlineDate',
          initialValue: '',
          placeholder: '请选择',
          rules: []
        },
        {
          type: 'RANGE_INPUT',
          label: '营业时间',
          fieldName: 'businessTimeRange',
          initialValue: ['9:00','18:00'],
          placeholder: '请输入',
          rules: [
            { validator: timeHourAndMin, trigger: 'blur'}
          ],
        },
        {
          type: 'INPUT',
          label: '通知接收邮箱',
          fieldName: 'noticeEmail',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 30,
          rules: [
            { validator: email, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: 'DMS系统管理员',
          fieldName: 'systemManager',
          placeholder: '请输入',
          initialValue: '',
          disabled:true,
          maxlength: 15,
        },
        {
          type: 'INPUT',
          label: '管理员联系电话',
          fieldName: 'sysManagerPhone',
          initialValue: '',
          maxlength: 20,
          rules: [
            { validator: phoneAndSolidifyNew, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: '投资人',
          fieldName: 'investor',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 15,
        },
        {
          type: 'INPUT',
          label: '投资人电话',
          fieldName: 'investorTel',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 16,
          rules: [
            { validator: phoneAndSolidifyNew, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: '投资人邮箱',
          fieldName: 'investorEmail',
          initialValue: '',
          placeholder: '请输入',
          maxlength: 30,
          rules: [
            { validator: email, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: '邮编',
          fieldName: 'zipCode',
          rows: 1,
          initialValue: '',
          placeholder: '请输入',
          maxlength: 6,
        },
        {
          type: 'SELECT',
          label: '网点类型',
          fieldName: 'branchType',
          placeholder: '请选择',
          initialValue: 16231001,
          disabled:true,
          itemList: this.createDictList('1623'),
          rules:bt,
          change: val => {
            this.changBranchTypeFunc(val);
          },
        },
        {
          type: 'INPUT',
          label: '上级单位',
          fieldName: 'upperDeptName',
          placeholder: '请选择',
          initialValue: '',
          disabled: true,
          rules: [],
          unitRender: () => {
            return (
              <div>
              <el-button icon="el-icon-search" onClick={() => this.searchFunc()}></el-button>
            </div>
          );
          }
        },
        {
          type: 'INPUT',
          label: '上级单位',
          fieldName: 'upperDept',
          placeholder: '请选择',
          initialValue: '',
          hidden: true,
        },
        {
          type: 'INPUT',
          label: '经度',
          fieldName: 'salesLongitude',
          rows: 1,
          initialValue: '',
          placeholder: '请输入经度',
          maxlength: 20,
          rules: [
            { validator: numberCheck, trigger: 'blur'}
          ]
        },
        {
          type: 'INPUT',
          label: '纬度',
          fieldName: 'salesLatitude',
          rows: 1,
          initialValue: '',
          placeholder: '请输入纬度',
          maxlength: 20,
          rules: [
            { validator: numberCheck, trigger: 'blur'}
          ]
        },

      ];
    },

    //网点类型选择
    changBranchTypeFunc(val){
      let bt = { required: true, message: '必填', trigger: ['change', 'blur'] };
      let btl = [bt]
      let initForm$upperDeptName = this.initForm.find(item => item.fieldName === 'upperDeptName');
      if(val == 16231002){
        initForm$upperDeptName.disabled = false;
        initForm$upperDeptName.rules = btl;
      }else{
        initForm$upperDeptName.disabled = true;
        initForm$upperDeptName.rules = [];
        initForm$upperDeptName.initialValue = "";
        this.$refs.FormPanel.CLEAR_VALIDATE();
      }
    },
    //经营状态选择
    changDealerStatus(val){
      let bt = { required: true, message: '必填', trigger: ['change', 'blur'] };
      let btl = [bt]
      let initForm$offlineDate = this.initForm.find(item => item.fieldName === 'offlineDate');
      if(val == 17241004){
        initForm$offlineDate.rules = btl;
      }else{
        initForm$offlineDate.rules = [];
        initForm$offlineDate.initialValue = "";
        this.$refs.FormPanel.CLEAR_VALIDATE();
      }
    },
    //上级单位选择
    searchFunc(){
      this.isSearch = true;
    },
    //上级单位选择结果更新
    upperClose(val, data) {
      console.log("upperDept:",data);
      if (data) {
        if(data[0].dealerAttachId == this.pdata.dealerAttachId){
          this.$notify.warning("上级单位不能选择当前经销商");
          return;
        }
        if(data[0].branchType != 16231001){
          this.$notify.warning("上级单位请选择一网经销商");
          return;
        }

        let initForm$upperDept = this.initForm.find(item => item.fieldName === 'upperDept');
        let initForm$upperDeptName = this.initForm.find(item => item.fieldName === 'upperDeptName');
        initForm$upperDept.initialValue = data[0].dealerAttachId;
        let formData = this.hiddenFormData;
        formData.upperDept = data[0].dealerAttachId;
        initForm$upperDeptName.initialValue = data[0].dealerName;

      }
      this.isSearch = false;
    },

    companyOpen(){
      this.companySearch = true;
    },

    companyClose(val, data){
      console.log("dealerData:", val);
      if(data) {
        let dealerCompanyId = this.initForm.find(item => item.fieldName === 'dealerCompanyId');
        let dealerCompanyCode = this.initForm.find(item => item.fieldName === 'dealerCompanyCode');
        let dealerCode = this.initForm.find(item => item.fieldName === 'dealerCode');
        let dealerCompanyName = this.initForm.find(item => item.fieldName === 'dealerCompanyName');
        let provinceId = this.initForm.find(item => item.fieldName === 'provinceId');
        let cityId = this.initForm.find(item => item.fieldName === 'cityId');
        let districtId = this.initForm.find(item => item.fieldName === 'districtId');
        let showroomAddress = this.initForm.find(item => item.fieldName === 'showroomAddress');
        let zipCode = this.initForm.find(item => item.fieldName === 'zipCode');
        let dealerName = this.initForm.find(item => item.fieldName === 'dealerName');
        let dealerNameEn = this.initForm.find(item => item.fieldName === 'dealerNameEn');
        let dealerShortname = this.initForm.find(item => item.fieldName === 'dealerShortname');
        let systemManager = this.initForm.find(item => item.fieldName === 'systemManager');
        let representative = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'representative');
        let representativeTel = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'representativeTel');
        let representativeEmail = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'representativeEmail');
        let registeredCapital = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'registeredCapital');
        let unifiedSocialCreditCode = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'unifiedSocialCreditCode');
        let establishmentDate = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'establishmentDate');
        let registerAddress = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'registerAddress');

        let caseUrl = this.$parent.$refs.infoPower.initForm.find(item => item.fieldName === 'caseUrl');
        this.$parent.$refs.infoPower.$refs.tableInfo.EXECUTE_INSERT(data[0].insertEquityList);

        let formData = this.hiddenFormData;
        formData.dealerCompanyId = data[0].companyId;
        formData.dealerCompanyCode = data[0].companyCode;
        dealerCompanyId.initialValue = data[0].companyId;
        dealerCompanyCode.initialValue = data[0].companyCode;
        dealerCode.initialValue = data[0].companyCode+'J';
        dealerCompanyName.initialValue = data[0].companyNameCn;
        provinceId.initialValue = data[0].provinceId;
        cityId.initialValue = data[0].cityId;
        districtId.initialValue = data[0].districtId;
        this.initRegion(data[0].provinceId, data[0].cityId);
        showroomAddress.initialValue = data[0].addressCn;
        zipCode.initialValue = data[0].zipCode;
        dealerName.initialValue = data[0].companyNameCn;
        dealerNameEn.initialValue = data[0].companyNameEn;
        dealerShortname.initialValue = data[0].companyShortNameCn;
        systemManager.initialValue = data[0].companyCode+'admin';
        representative.initialValue = data[0].representative;
        representativeTel.initialValue = data[0].representativeTel;
        representativeEmail.initialValue = data[0].representativeEmail;
        registeredCapital.initialValue = data[0].registeredCapital;
        unifiedSocialCreditCode.initialValue = data[0].unifiedSocialCreditCode;
        establishmentDate.initialValue = moment(data[0].establishmentDate).format('YYYY-MM-DD HH:MM:SS');
        registerAddress.initialValue = data[0].registerAddress;
        caseUrl.initialValue = data[0].caseUrl;
      }
      this.companySearch = false;
    },

  }
};
</script>
